package com.ruoyi.vehicle.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.vehicle.domain.TbThreshold;
import com.ruoyi.vehicle.service.ITbThresholdService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 时间阀值设置Controller
 * 
 * @author ruoyi
 * @date 2025-08-18
 */
@RestController
@RequestMapping("/threshold")
public class TbThresholdController extends BaseController
{
    @Autowired
    private ITbThresholdService tbThresholdService;

    /**
     * 查询时间阀值设置列表
     */
    //@RequiresPermissions("vehicle:threshold:list")
    @GetMapping("/list")
    public TableDataInfo list(TbThreshold tbThreshold)
    {
        startPage();
        List<TbThreshold> list = tbThresholdService.selectTbThresholdList(tbThreshold);
        return getDataTable(list);
    }

    /**
     * 导出时间阀值设置列表
     */
    //@RequiresPermissions("vehicle:threshold:export")
    @Log(title = "时间阀值设置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbThreshold tbThreshold)
    {
        List<TbThreshold> list = tbThresholdService.selectTbThresholdList(tbThreshold);
        ExcelUtil<TbThreshold> util = new ExcelUtil<TbThreshold>(TbThreshold.class);
        util.exportExcel(response, list, "时间阀值设置数据");
    }

    /**
     * 获取时间阀值设置详细信息
     */
    //@RequiresPermissions("vehicle:threshold:query")
    @GetMapping(value = "/{thresholdId}")
    public AjaxResult getInfo(@PathVariable("thresholdId") Long thresholdId)
    {
        return success(tbThresholdService.selectTbThresholdByThresholdId(thresholdId));
    }

    /**
     * 新增时间阀值设置
     */
    //@RequiresPermissions("vehicle:threshold:add")
    @Log(title = "时间阀值设置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbThreshold tbThreshold)
    {
        return toAjax(tbThresholdService.insertTbThreshold(tbThreshold));
    }

    /**
     * 修改时间阀值设置
     */
    //@RequiresPermissions("vehicle:threshold:edit")
    @Log(title = "时间阀值设置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbThreshold tbThreshold)
    {
        return toAjax(tbThresholdService.updateTbThreshold(tbThreshold));
    }

    /**
     * 删除时间阀值设置
     */
    //@RequiresPermissions("vehicle:threshold:remove")
    @Log(title = "时间阀值设置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{thresholdIds}")
    public AjaxResult remove(@PathVariable Long[] thresholdIds)
    {
        return toAjax(tbThresholdService.deleteTbThresholdByThresholdIds(thresholdIds));
    }
}
